define(function(require, exports, module){
	var membershipTemp = require("text!../template/membership.html");
	
	module.exports = Nuui.View.extend({
		
		template:membershipTemp,
		
		onRender:function(){
			var view = this;
            App.request(App.server.getServePath(App.path.getSessionId), {
                success:function(data){
                    if(data.ec){
                        alert(data.em);
                    }else{
                        var res=data.body;
                        view.$("#loginName").val(res.loginName);
                        view.$("#nickMoney").val(res.nickMoney);
                        view.$("#level").val(res.level);
                        view.$("#useName").val(res.useName);
                        view.$("#nickName").val(res.nickName);
                        view.$("#email").val(res.email);
                        view.$("#idCard").val(res.idCard);
                        view.$("#phoneNo").val(res.phoneNo);
                        view.$("#qq").val(res.qq);
                        view.$("#waChat").val(res.waChat);
                        view.$("#aliPay").val(res.aliPay);
                        var radios=view.$('.radio p');
                        radios.each(function(i,v){
                        	if(res.gender==$(v).attr('data-code')){
                        		radios.removeClass('active');
                        		$(v).addClass('active');
                        		}
                        })
                    }
                }
            })
		},
		
		onShow:function(){
			 var view=this;
			 view.$('.radio p').on('tap','span',function(){
			 	var radio=$(this).closest('p');
			 	if(radio.hasClass('active')){
			 		return false;
			 	}else{
			 		radio.addClass('active').siblings().removeClass('active');
			 		
			 	}

			 })
		}
		
	});	
});